package com.zhq.zhq_blog.controller;

import com.zhq.zhq_blog.entity.result.ResultBean;
import com.zhq.zhq_blog.exception.BusinessException;
import com.zhq.zhq_blog.exception.CodeEnum;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("test")
public class TestController {
    //postman 访问http://localhost:10001/test/hello 返回hello 说明项目启动成功了
    @RequestMapping("hello")
    public String hello(){
        return "hello";
    }
    @RequestMapping("hello_result")
    public ResultBean hello_result(){
        return ResultBean.success("haha");
    }
    @RequestMapping("error1")
    public ResultBean error1(){
        throw new BusinessException(CodeEnum.BAD_REQUEST);
    }
    @RequestMapping("error2")
    public ResultBean error2(){
        throw new NullPointerException();
    }
    @RequestMapping("error3")
    public ResultBean error3() {
        Integer.parseInt("abc123");
        return ResultBean.success("error3");
    }

}
